package com.zsrt.devbase.common.utils;

import java.io.File;
import java.io.IOException;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.multipart.MultipartFile;

public class ImageLoadUtil {

	// public static final String FILE_PATH = "/PlatForm/images/company"; //保存文件路径默认D:
	   
	 //文件上传  
	    public static String uploadFile(MultipartFile businessLicenseImg,String loadPath, HttpServletRequest request) throws IOException {  
	        String fileName = businessLicenseImg.getOriginalFilename();  
	        File tempFile = new File(loadPath, new Date().getTime() + String.valueOf(fileName));  
	        if (!tempFile.getParentFile().exists()) {  
	            tempFile.getParentFile().mkdir();  
	        }  
	        if (!tempFile.exists()) {  
	            tempFile.createNewFile();  
	        }  
	        businessLicenseImg.transferTo(tempFile);  
	       // return "/download/" + tempFile.getName();  
	        return "download?fileName=" + tempFile.getName();  //返回下载路径
	    }  
	    public static File getFile(String fileName,String loadPath) {  
	        return new File(loadPath, fileName);  
	    }  
	}  